package net.zjitc.servlet.category;

import net.zjitc.domain.Category;
import net.zjitc.service.CategoryService;
import net.zjitc.service.impl.CategoryServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * 2 * @Author: 洪瑶
 * 3 * @Date: 2018/10/19 15:12
 * 4
 */
@WebServlet(name = "UpdateUIServlet",urlPatterns = "/updateuiServlet")
public class UpdateUIServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String cid = request.getParameter("cid");
        int id = Integer.parseInt(cid);
        CategoryService service = new CategoryServiceImpl();
        Category category = null;
        try {
            category = service.findBy(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        request.setAttribute("category",category);
        request.getRequestDispatcher("/common/category/update.jsp").forward(request,response);
    }
}
